package org.hongqi.common.senpec.base.mybatisplus;

import com.baomidou.mybatisplus.core.metadata.IPage;
import jakarta.servlet.http.HttpServletResponse;
import org.hongqi.common.senpec.base.sevlet.Result;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Collection;

@RestController
public interface IBaseController<T> {
    @PostMapping
    Result<T> save(T entity);

    @DeleteMapping("/{id}")
    Result<?> removeById(@PathVariable("id") Long id);

    @PutMapping
    Result<T> updateById(T entity);

    @GetMapping("/{id}")
    Result<T> getById(@PathVariable(name = "id") Long id);

    @PostMapping("/getOne")
    default Result<T> getOne(T entity) {
        return Result.ok(entity);
    }

    @PostMapping("/listObjsWithPage")
    default Result<IPage<T>> listObjsWithPage(T entity) {
        return null;
    }

    @PostMapping("/listObjsWithoutPage")
    default Result<Collection<T>> listObjsWithoutPage(T entity) {
        return null;
    }

    @PostMapping("/listTree")
    default Result<Collection<T>> listTree(T entity) {
        return null;
    }

    @GetMapping("/exportObjs")
    default void exportObjs(HttpServletResponse response) {
    }

    @PostMapping("/importObjs/{creator}")
    default void importObjs(@PathVariable("creator") Long creator, MultipartFile file) throws IOException {
    }
}
